package de.hauschild.gmltracer.gml.impl.value.real;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.integer.IntegerToken;

public class FloorRealOperatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final RealToken value = tokenStack.pop(RealToken.class);

    final Integer result = Double.valueOf(Math.floor(value.getValue())).intValue();
    tokenStack.push(new IntegerToken(result));
  }

  @Override
  public String toString() {
    return "floor";
  }
}
